<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      while (true) {
        let year = Number(prompt('请您输入年份！'))
        let month = Number(prompt('请您输入月份！'))
        let day = 0
        switch (month) {
          case 1:
          case 3:
          case 5:
          case 7:
          case 8:
          case 10:
          case 12:
            day = 31
            break
          case 4:
          case 6:
          case 9:
          case 11:
            day = 30
            break
          case 2:
            if (year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)) {
              day = 29
            } else {
              day = 28
            }
            break
        }
        if (month <= 12 && month > 0) {
          alert(`${year}年的${month}月有${day}天`)
          break
        } else {
          alert('请您重新输入！')
        }
      }
    </script>
  </body>
</html>
